package com.hjxy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hjxy.dao.AttendanceDao;
import com.hjxy.pojo.StudentAtt;
import com.hjxy.service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

//考勤查询（ztt）
@Service
public class AttendanceServiceImpl implements AttendanceService {
    private AttendanceDao attendanceDao;

//    将Dao层的AttendanceDao装配到IOC容器
    @Autowired
    public AttendanceServiceImpl(AttendanceDao attendanceDao){
        this.attendanceDao = attendanceDao;
    }

//    查询所有学生考勤
    @Override
    public List<StudentAtt> selectAll() {
        return attendanceDao.selectAll();
    }

//    查询个体学生考勤
    @Override
    public List<StudentAtt> selectOne() {

        return null;
    }

    @Override
    public PageInfo<StudentAtt> updatePage(Integer currentPage, Integer pageSize) {
        //准备拦截mybatis后续的查询
        PageHelper.startPage(currentPage, pageSize);
        List<StudentAtt> list = attendanceDao.updatePage();
        //pagehelper内部计算总共有多少页
        PageInfo<StudentAtt> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public StudentAtt getEdit(Integer sno) {
        return attendanceDao.getEdit(sno);
    }


    @Override
    public int saveEdit(StudentAtt dataValue) {
        int result = attendanceDao.saveEdit(dataValue);
        return result;
    }

    @Override
    public int addEdit(StudentAtt dataValue) {
        int result = attendanceDao.addEdit(dataValue);
        return result;
    }

    @Override
    public int removeEdit(Integer sno) {
        return attendanceDao.removeEdit(sno);
    }
}
